<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title> 小程序管理系统</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="apple-mobile-web-app-status-bar-style" content="black"> 
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="format-detection" content="telephone=no">
  
  <link rel="stylesheet" href="/201706/zltc/Public/layui/css/layui.css"  media="all">
  <style type="text/css">
    
  </style>
</head>
<body>
<div class="layui-layout layui-layout-admin">
  <div class="layui-header">
    <div class="layui-logo">  </div>
    <!-- 头部区域（可配合layui已有的水平导航） -->
    <ul class="layui-nav layui-layout-left">
      <li class="layui-nav-item"><a href="<?php echo U('Index/index');?>">首页</a></li>
      <li class="layui-nav-item layui-this"><a href="<?php echo U('InfoCate/index');?>">分类信息管理</a></li>
      <li class="layui-nav-item"><a href="<?php echo U('ShopCate/index');?>">好店管理</a></li>
      <li class="layui-nav-item"><a href="<?php echo U('Quan/index');?>">同城圈管理</a></li>
      <li class="layui-nav-item"><a href="<?php echo U('Member/index');?>">用户管理</a></li>
      <li class="layui-nav-item"><a href="<?php echo U('Home/Index/index');?>">切换小程序</a></li>
    </ul>
    <ul class="layui-nav layui-layout-right">
      <li class="layui-nav-item">
        <a href="javascript:;">
          <img src="<?php echo ($_SESSION['wechat']['headimg']); ?>" class="layui-nav-img">
          <?php echo ($_SESSION['wechat']['nickname']); ?>
        </a>
        <dl class="layui-nav-child">
          <dd><a href="<?php echo U('Home/Index/index');?>">切换小程序</a></dd>
          <!-- <dd><a href="">安全设置</a></dd> -->
        </dl>
      </li>
      <li class="layui-nav-item">
        <a href="javascript:;">
          <img src="<?php echo (session('headimgurl')); ?>" class="layui-nav-img">
          <?php echo (session('nickname')); ?>
        </a>
        <dl class="layui-nav-child">
          <dd><a href="<?php echo U('Public/logout');?>">退出登录</a></dd>
          <!-- <dd><a href="">安全设置</a></dd> -->
        </dl>
      </li>
    </ul>
  </div>
  
  <div class="layui-side layui-bg-black">
    <div class="layui-side-scroll">
      <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
      <ul class="layui-nav layui-nav-tree"  lay-filter="test">
        <li class="layui-nav-item"><a href="<?php echo U('InfoCate/index');?>">分类管理</a></li>
        <li class="layui-nav-item layui-this"><a href="<?php echo U('House/index');?>">房产信息管理</a></li>
        <li class="layui-nav-item"><a href="<?php echo U('Job/index');?>">招聘信息管理</a></li>
        <li class="layui-nav-item"><a href="<?php echo U('Pinche/index');?>">拼车信息管理</a></li>
        <li class="layui-nav-item"><a href="<?php echo U('Info/index');?>">通用信息管理</a></li>
      </ul>
    </div>
  </div>
  
  <div class="layui-body">
    <!-- 内容主体区域 -->
    <div style="padding:0 15px;">
      <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
        <legend>房产信息管理</legend>
      </fieldset>
      <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
        <ul class="layui-tab-title">
          <li class="layui-this">新房</li>
          <li>二手房</li>
          <li>租房</li>
        </ul>
        <div class="layui-tab-content">
          <div id="view1" class="layui-tab-item layui-show"></div>
          <div id="view2" class="layui-tab-item"></div>
          <div id="view3" class="layui-tab-item"></div>
        </div>
      </div>
    </div>
  </div>
  
  <div class="layui-footer">
    <!-- 底部固定区域 -->
    © 2017-2018 <a href="http://www.58zltc.com" target="_blank">  </a> All Rights Reserved.
  </div>
</div>
<script id="new_tpl" type="text/html">
  <table class="layui-table">
    <thead>
      <tr>
        <th>ID</th>
        <th>楼盘名称</th>
        <th>均价</th>
        <th>开发商</th>
        <th>联系电话</th>
        <th>发布时间</th>
        <th>操作</th>
      </tr> 
    </thead>
    <tbody>
      {{#  layui.each(d, function(index, item){ }}
      <tr>
        <td>{{ item.id }}</td>
        <td>{{ item.title }}</td>
        <td>{{ item.price }}元/月</td>
        <td>{{ item.house_company }}</td>
        <td>{{ item.tel }}</td>
        <td>{{ item.create_time }}</td>
        <td>
          {{#  if(item.is_top == 1){ }}
          <button data-id="{{ item.id }}" data-status="0" class="top layui-btn layui-btn-small">取消置顶</button>
          {{#  }else{ }}
          <button data-id="{{ item.id }}" data-status="1" class="top layui-btn layui-btn-small">置顶</button>
          {{#  } }}
          {{#  if(item.is_tui == 1){ }}
          <button data-id="{{ item.id }}" data-status="0" class="tui layui-btn layui-btn-small">取消推荐</button>
          {{#  }else{ }}
          <button data-id="{{ item.id }}" data-status="1" class="tui layui-btn layui-btn-small">推荐</button>
          {{#  } }}
          <button data-id="{{ item.id }}" class="del layui-btn layui-btn-small">删除</button>
        </td>
      </tr>
      {{#  }); }}
      {{#  if(d.length === 0){ }}
        无数据
      {{#  } }}
    </tbody>
  </table>
  <div id="page-box1"></div>
</script>
<script id="ershou_tpl" type="text/html">
  <table class="layui-table">
    <thead>
      <tr>
        <th>ID</th>
        <th>标题</th>
        <th>总价</th>
        <th>联系人</th>
        <th>联系电话</th>
        <th>发布时间</th>
        <th>操作</th>
      </tr> 
    </thead>
    <tbody>
      {{#  layui.each(d, function(index, item){ }}
      <tr>
        <td>{{ item.id }}</td>
        <td>{{ item.title }}</td>
        <td>{{ item.price }}元/月</td>
        <td>{{ item.username }}</td>
        <td>{{ item.tel }}</td>
        <td>{{ item.create_time }}</td>
        <td>
          {{#  if(item.is_top == 1){ }}
          <button data-id="{{ item.id }}" data-status="0" class="top layui-btn layui-btn-small">取消置顶</button>
          {{#  }else{ }}
          <button data-id="{{ item.id }}" data-status="1" class="top layui-btn layui-btn-small">置顶</button>
          {{#  } }}
          {{#  if(item.is_tui == 1){ }}
          <button data-id="{{ item.id }}" data-status="0" class="tui layui-btn layui-btn-small">取消推荐</button>
          {{#  }else{ }}
          <button data-id="{{ item.id }}" data-status="1" class="tui layui-btn layui-btn-small">推荐</button>
          {{#  } }}
          <button data-id="{{ item.id }}" class="del layui-btn layui-btn-small">删除</button>
        </td>
      </tr>
      {{#  }); }}
      {{#  if(d.length === 0){ }}
        无数据
      {{#  } }}
    </tbody>
  </table>
  <div id="page-box2"></div>
</script>
<script id="zufang_tpl" type="text/html">
  <table class="layui-table">
    <thead>
      <tr>
        <th>ID</th>
        <th>标题</th>
        <th>租金</th>
        <th>联系人</th>
        <th>联系电话</th>
        <th>发布时间</th>
        <th>操作</th>
      </tr> 
    </thead>
    <tbody>
      {{#  layui.each(d, function(index, item){ }}
      <tr>
        <td>{{ item.id }}</td>
        <td>{{ item.title }}</td>
        <td>{{ item.price }}元/月</td>
        <td>{{ item.username }}</td>
        <td>{{ item.tel }}</td>
        <td>{{ item.create_time }}</td>
        <td>
          {{#  if(item.is_top == 1){ }}
          <button data-id="{{ item.id }}" data-status="0" class="top layui-btn layui-btn-small">取消置顶</button>
          {{#  }else{ }}
          <button data-id="{{ item.id }}" data-status="1" class="top layui-btn layui-btn-small">置顶</button>
          {{#  } }}
          {{#  if(item.is_tui == 1){ }}
          <button data-id="{{ item.id }}" data-status="0" class="tui layui-btn layui-btn-small">取消推荐</button>
          {{#  }else{ }}
          <button data-id="{{ item.id }}" data-status="1" class="tui layui-btn layui-btn-small">推荐</button>
          {{#  } }}
          <button data-id="{{ item.id }}" class="del layui-btn layui-btn-small">删除</button>
        </td>
      </tr>
      {{#  }); }}
      {{#  if(d.length === 0){ }}
        无数据
      {{#  } }}
    </tbody>
  </table>
  <div id="page-box3"></div>
</script>
<script src="/201706/zltc/Public/layui/layui.js" charset="utf-8"></script>
<script>
//JavaScript代码区域
layui.use(['element','laypage','laytpl','layer'], function(){
  var element = layui.element
  ,$ = layui.jquery
  ,layer = layui.layer
  ,laypage = layui.laypage
  ,laytpl = layui.laytpl;

  $(".layui-tab-content").on('click', '.top', function(event) {
    var id = $(this).data('id');
    var status = $(this).data('status');
    $.post("<?php echo U('top');?>", {id: id, status: status}, function(e) {
      if(e.status == 1){
        layer.msg(e.info,{icon: 6,time:1000});
        setTimeout("location.reload()",1000);
      }else{
        layer.msg(e.info,{icon:1,time:1000});
      }
    });
  });

  $(".layui-tab-content").on('click', '.del', function(event) {
    var id = $(this).data('id');
    $.post("<?php echo U('del');?>", {id: id}, function(e) {
      if(e.status == 1){
        layer.msg(e.info,{icon: 6,time:1000});
        setTimeout("location.reload()",1000);
      }else{
        layer.msg(e.info,{icon:1,time:1000});
      }
    });
  });

  $(".layui-tab-content").on('click', '.tui', function(event) {
    var id = $(this).data('id');
    var status = $(this).data('status');
    $.post("<?php echo U('tui');?>", {id: id, status: status}, function(e) {
      if(e.status == 1){
        layer.msg(e.info,{icon: 6,time:1000});
        setTimeout("location.reload()",1000);
      }else{
        layer.msg(e.info,{icon:1,time:1000});
      }
    });
  });

  getList(1, 1, 10);
  getList(2, 1, 10);
  getList(3, 1, 10);
  function getList(type, page, limit){
    $.get("<?php echo U('index');?>?type="+type+"&page="+page+"&limit="+limit,function(data){
      var view = document.getElementById('view'+type);
      if(type == 1){
        var getTpl = new_tpl.innerHTML;
      }else if(type == 2){
        var getTpl = ershou_tpl.innerHTML;
      }else if(type == 3){
        var getTpl = zufang_tpl.innerHTML;
      }
      laytpl(getTpl).render(data.list, function(html){
        view.innerHTML = html;
      });
      laypage.render({
        elem: 'page-box'+type
        ,count: data.count
        ,curr: page
        ,layout: ['count', 'prev', 'page', 'next', 'limit', 'skip']
        ,jump: function(obj, first){
          console.log(obj)
          if(!first){
            getList(type, obj.curr, obj.limit);
          }
        }
      });
    })
  }  
});
</script>
</body>
</html>